﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="detailandmed_kaardile_kantud_isik", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(DetailandmedKaardileKantudIsik))]
    public class DetailandmedKaardileKantudIsikSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IDetailandmedKaardileKantudIsik clazz;
        
        public DetailandmedKaardileKantudIsikSerializer(IDetailandmedKaardileKantudIsik clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.KaardiPiirkond!=null) {
                Writer.WriteStartElement("kaardi_piirkond");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.KaardiPiirkond))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KaardiNr!=null) {
                Writer.WriteStartElement("kaardi_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.KaardiNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KaardiTyyp!=null) {
                Writer.WriteStartElement("kaardi_tyyp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KaardiTyyp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KandeNr!=null) {
                Writer.WriteStartElement("kande_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.KandeNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.IsikuTyyp!=null) {
                Writer.WriteStartElement("isiku_tyyp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuTyyp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.IsikuRoll!=null) {
                Writer.WriteStartElement("isiku_roll");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuRoll))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.IsikuRollTekstina!=null) {
                Writer.WriteStartElement("isiku_roll_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuRollTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Eesnimi!=null) {
                Writer.WriteStartElement("eesnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.NimiArinimi!=null) {
                Writer.WriteStartElement("nimi_arinimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.NimiArinimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.IsikukoodRegistrikood!=null) {
                Writer.WriteStartElement("isikukood_registrikood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikukoodRegistrikood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ValisKood!=null) {
                Writer.WriteStartElement("valis_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ValisKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Synniaeg!=null) {
                Writer.WriteStartElement("synniaeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Synniaeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Osamaks!=null) {
                Writer.WriteStartElement("osamaks");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Osamaks))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OsamaksuValuuta!=null) {
                Writer.WriteStartElement("osamaksu_valuuta");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OsamaksuValuuta))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OsamaksuValuutaTekstina!=null) {
                Writer.WriteStartElement("osamaksu_valuuta_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OsamaksuValuutaTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.VolitusteLoppemiseKpv!=null) {
                Writer.WriteStartElement("volituste_loppemise_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.VolitusteLoppemiseKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressRiik!=null) {
                Writer.WriteStartElement("aadress_riik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressRiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressRiikTekstina!=null) {
                Writer.WriteStartElement("aadress_riik_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressRiikTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressEhak!=null) {
                Writer.WriteStartElement("aadress_ehak");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressEhak))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressEhakTekstina!=null) {
                Writer.WriteStartElement("aadress_ehak_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressEhakTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressTanavMajaKorter!=null) {
                Writer.WriteStartElement("aadress_tanav_maja_korter");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressTanavMajaKorter))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKpv!=null) {
                Writer.WriteStartElement("algus_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoppKpv!=null) {
                Writer.WriteStartElement("lopp_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKpv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="kaardi_piirkond") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>kaardi_piirkond");
                }
                clazz.KaardiPiirkond = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("kaardi_piirkond")).Value;
            }
            if (Reader.LocalName=="kaardi_nr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>kaardi_nr");
                }
                clazz.KaardiNr = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("kaardi_nr")).Value;
            }
            if (Reader.LocalName=="kaardi_tyyp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>kaardi_tyyp");
                }
                clazz.KaardiTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kaardi_tyyp")).Value;
            }
            if (Reader.LocalName=="kande_nr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>kande_nr");
                }
                clazz.KandeNr = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("kande_nr")).Value;
            }
            if (Reader.LocalName=="isiku_tyyp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>isiku_tyyp");
                }
                clazz.IsikuTyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isiku_tyyp")).Value;
            }
            if (Reader.LocalName=="isiku_roll") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>isiku_roll");
                }
                clazz.IsikuRoll = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isiku_roll")).Value;
            }
            if (Reader.LocalName=="isiku_roll_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>isiku_roll_tekstina");
                }
                clazz.IsikuRollTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isiku_roll_tekstina")).Value;
            }
            if (Reader.LocalName=="eesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>eesnimi");
                }
                clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
            }
            if (Reader.LocalName=="nimi_arinimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>nimi_arinimi");
                }
                clazz.NimiArinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("nimi_arinimi")).Value;
            }
            if (Reader.LocalName=="isikukood_registrikood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>isikukood_registrikood");
                }
                clazz.IsikukoodRegistrikood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood_registrikood")).Value;
            }
            if (Reader.LocalName=="valis_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>valis_kood");
                }
                clazz.ValisKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("valis_kood")).Value;
            }
            if (Reader.LocalName=="synniaeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>synniaeg");
                }
                clazz.Synniaeg = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("synniaeg")).Value;
            }
            if (Reader.LocalName=="osamaks") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>osamaks");
                }
                clazz.Osamaks = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("osamaks")).Value;
            }
            if (Reader.LocalName=="osamaksu_valuuta") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>osamaksu_valuuta");
                }
                clazz.OsamaksuValuuta = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("osamaksu_valuuta")).Value;
            }
            if (Reader.LocalName=="osamaksu_valuuta_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>osamaksu_valuuta_tekstina");
                }
                clazz.OsamaksuValuutaTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("osamaksu_valuuta_tekstina")).Value;
            }
            if (Reader.LocalName=="volituste_loppemise_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>volituste_loppemise_kpv");
                }
                clazz.VolitusteLoppemiseKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("volituste_loppemise_kpv")).Value;
            }
            if (Reader.LocalName=="aadress_riik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>aadress_riik");
                }
                clazz.AadressRiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_riik")).Value;
            }
            if (Reader.LocalName=="aadress_riik_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>aadress_riik_tekstina");
                }
                clazz.AadressRiikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_riik_tekstina")).Value;
            }
            if (Reader.LocalName=="aadress_ehak") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>aadress_ehak");
                }
                clazz.AadressEhak = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_ehak")).Value;
            }
            if (Reader.LocalName=="aadress_ehak_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>aadress_ehak_tekstina");
                }
                clazz.AadressEhakTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_ehak_tekstina")).Value;
            }
            if (Reader.LocalName=="aadress_tanav_maja_korter") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>aadress_tanav_maja_korter");
                }
                clazz.AadressTanavMajaKorter = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_tanav_maja_korter")).Value;
            }
            if (Reader.LocalName=="algus_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>algus_kpv");
                }
                clazz.AlgusKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kpv")).Value;
            }
            if (Reader.LocalName=="lopp_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kaardile_kantud_isik>lopp_kpv");
                }
                clazz.LoppKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kpv")).Value;
            }
        }
    }
}
